Odoo / Model / Filtering - Domain
Filtering using domain
-
Step 1:
Syntax
('field_name', 'operator', value) 1.field_name : a valid name of field of the object model or in the database table
2. operator : valid operators are =, !=, >, >=,
3. value : a valid value to compare with the values of field_name, depending on its type1. Single condition
if field1 = 10
domain = [('field1','=',10)] OR domain = [('field1','=','field2')] 2. Condition AND
if field1 = 5 and field2 = 10
domain = [('field1','=',5),('field2','=',10)] OR domain = [('field1','=',field3),('field1','=',field3)] 3. Condition OR
if field1 = 5 or field2 = 10
domain = ['|', ('field1','=',5),('field2','=',10)] OR domain = ['|', ('field1','=',field3),('field1','=',field3)] 4. Multiple Condition
field1 = 5 or (field2 ! = 10 and field3 = 12)
domain = ['|',('field1','=',5),('&',('field2','!=',10),('field3','=','12'))